package com.message.controller;

import com.code.domain.CommonResult;
import com.message.service.IProviderService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j
@RequestMapping(value = "/provider")
public class ProviderController {

    @Autowired
    private IProviderService providerService;

    @ApiOperation(value = "向mq推送消息", notes = "向mq推送消息")
    @GetMapping("/send/{str}")
    public @ResponseBody
    CommonResult send(@PathVariable("str") String str) {
        log.info("controller 向 mq 推送消息====>" + str);
        boolean flag = providerService.send(str);
        if (flag) {
            return new CommonResult();
        } else {
            new Thread("推送失败");
        }
        return null;
    }
}
